package com.zemo.tools;

/**
//文档生成日期：2005.10.07
//
//(1)概述：
//类名称：SResources
//类说明：
//??	?? 将本应用中所有的固定字符串均集中于此,声明为static变量
* 
//所在子系统：RssOwlMIDlet
//
//系统总描述:
	    我们提供的RSS无线阅读器J2ME版本[开源]是一个可以下载到手机(例如Nokia7610)或者其他无线手持设备(例如PocketPC)的应用程序，用来阅读存在于Internet中广泛的RSS新闻源。

	 子系统描述：
		RSS无线阅读器的功能列表：
	RSS Feed列表
		添加Rss Feed
		编辑Rss Feed
		删除Rss Feed
	读取Rss Feed新闻
		查看新闻摘要
		重新读取Rss Feed新闻
	关于我


//(2)历史记录:
//创建人: 郑昀(2005.10.07)
//联系我: Google Talk >> zhengyun@gmail.com
//Blogs:    http://blog.csdn.net/zhengyun_ustc/以及http://www.cnblogs.com/zhengyun_ustc

//(3)版权声明:
//由于我这个版本的RSS J2ME阅读器也是基于Tommi和garrey源代码基础上改编而来的，
//所以决定遵照GPL协议的大意开放源代码，您可以自由传播和修改，在遵照GPL协议的约束条件的前提下。

//(4)相关资源:
1：《[J2ME]RSSOwlMidlet(RSS无线阅读器)开源说明》
2：《[J2ME]RSSOwlMidlet(RSS无线阅读器)设计说明》
3：下载源代码：

////////////////////////////////////////////////////////////////////*/

import java.util.Hashtable;

import javax.microedition.lcdui.Image;


/**********************************************************
//SResources
//
//Class Description:
//	提供一些常用的字符串资源
//
//Author:
//   zhengyun@ultrapower 2005.10.07
//
**********************************************************/
public class SResources {
	/*
	 * RecordStore名
	 */
	public static final String RECORDSTORE_NAME = "RSSFEEDS_LIST";
	
	/*
	 * Feed列表最大的数目
	 */
	public static final int MAX_FEEDS = 15;
		
	  // Image keys
	  private static final int OFFSET_IMG = 100;
	  public static final int IMG_ABOUT	= 100;
	  public static final int IMG_FEEDLIST = 101;
	  public static final int IMG_FEEDADD = 102;
	  public static final int IMG_UNREADFEED = 103;
	  public static final int IMG_EDITFEED = 104;
	  public static final int IMG_ERROR = 105;
	  
	  /** Image cache */
	  protected static Hashtable m_images = new Hashtable();
	  
	  // Image resource names
	  protected static final String[] IMGNAME_MAP ={
	    "promotion.PNG",
	    "feed.PNG",
	    "add_feed.PNG",
	    "feed_unread.PNG",
	    "editrssfeed.PNG",
	    "error.PNG",
	  };
	  
	  /**
	   * Returns specified image.
	   * @param id  The id of the image.
	   * @return    An image.
	   */
	  public static synchronized Image getImage(int id)
	  {
	    id -= OFFSET_IMG;
	    Image img = (Image)m_images.get(new Integer(id));
	    if (img == null)
	    {
	      try
	      {
			  /*
			   * 注意原来这里写的是"/" +，始终无法加载图像；
			   * 所以我改为了"/res/" + 
			   */
	        img = Image.createImage("/res/icon/" + IMGNAME_MAP[id]);
			System.out.println("get image:/res/icon/" + IMGNAME_MAP[id]);
	        m_images.put(new Integer(id), img);
	      }
	      catch (Exception e)
	      {
	        System.out.println("Error getting resource img " + IMGNAME_MAP[id]
	           + ">>" + e.getMessage());
	        e.printStackTrace();
	      }
	    }
	    return img;
	  }
	  
	/*
	 * 菜单的名字:
	 */
	public static String MENU_COMMAND_QUIT = "退出";
	public static String MENU_COMMAND_READRSSFEED = "读取新闻";
	public static String MENU_COMMAND_ADDRSSFEED = "添加书签";
	public static String MENU_COMMAND_EDITRSSFEED = "编辑书签";
	public static String MENU_COMMAND_DELETERSSFEED = "删除书签";
	public static String MENU_COMMAND_ABOUTME = "关于我";
	public static String MENU_COMMAND_VIEWDETAIL = "浏览摘要";
	public static String MENU_COMMAND_BACKCMD = "返回";
	public static String MENU_COMMAND_UPDATENEWS = "重新读取新闻";
	
	/*
	 * Form的Title名称:
	 */
	public static String FORM_TITLE_FEEDLIST = "RSS无线阅读器 - Rss Feeds";
	public static String FORM_TITLE_READRSSFEED = "RSS无线阅读器 - 读取新闻";
	public static String FORM_TITLE_ADDRSSFEED = "RSS无线阅读器 - 添加书签";
	public static String FORM_TITLE_VIEWNEWS = "RSS无线阅读器 - 查看新闻摘要";
	public static String FORM_TITLE_EDITRSSFEED = "RSS无线阅读器 - 编辑RSS书签";
	public static String FORM_TITLE_ABOUTME = "RSS无线阅读器 - 关于我";
	
	  // Text keys
	  private static int TXTID = 0;
	  // text / page titles
	  public static final int TXT_T_RSSFEED1 = TXTID++;
	  public static final int TXT_T_RSSFEED2 = TXTID++;
	  public static final int TXT_T_RSSFEED3 = TXTID++;
	  public static final int TXT_T_RSSFEED4 = TXTID++;
	  public static final int TXT_T_RSSFEED5 = TXTID++;
	  public static final int TXT_T_RSSFEED6 = TXTID++;
	  public static final int TXT_T_RSSFEED7 = TXTID++;
	  // command text
	  	public static int TXT_T_MENU_COMMAND_QUIT = TXTID++;
		public static int TXT_T_MENU_COMMAND_READRSSFEED = TXTID++;
		public static int TXT_T_MENU_COMMAND_ADDRSSFEED = TXTID++;
		public static int TXT_T_MENU_COMMAND_EDITRSSFEED = TXTID++;
		public static int TXT_T_MENU_COMMAND_DELETERSSFEED = TXTID++;
		public static int TXT_T_MENU_COMMAND_ABOUTME = TXTID++;
		public static int TXT_T_MENU_COMMAND_VIEWDETAIL = TXTID++;
		public static int TXT_T_MENU_COMMAND_BACKCMD = TXTID++;
		public static int TXT_T_MENU_COMMAND_UPDATENEWS = TXTID++;
	
	  /*
		 * 预定义的Rss Feed名称以及URL:
		 */
	  protected static final char[][] TEXTBUF = {
		  "DOUBAN MOVIE|http://www.douban.com/feed/review/latest".toCharArray(),
		  "JOYCODE|http://blog.joycode.com/MainFeed.aspx".toCharArray(),
		  "CNBlogs|http://www.cnblogs.com/rss.aspx".toCharArray(),
		  "CSDN Tech|http://blog.csdn.net/zemochen/rss/list".toCharArray(),
		  "ChinaUnix.net|http://bbs.chinaunix.net/rss/46.xml".toCharArray(),
		  "keso's blog|http://feeds.feedburner.com/PlayinWithIt".toCharArray(),
		  "Zhengyun|http://blog.csdn.net/zhengyun_ustc/Rss.aspx".toCharArray(),
		  
		  
		  /*
		   * 按钮的命令文字
		   */
		  	"退出".toCharArray(),
			"读取新闻".toCharArray(),
			"添加书签".toCharArray(),
			"编辑书签".toCharArray(),
			"删除书签".toCharArray(),
			"关于我".toCharArray(),
			"浏览摘要".toCharArray(),
			"返回".toCharArray(),
			"重新读取新闻".toCharArray(),
	  };
	  
	
	/**
	   * Returns specified text as character array.
	   * @param id  The id of the text.
	   * @return    A text as char array.
	   */
	  public static char[] getChars(int id)
	  {
	    return TEXTBUF[id];
	  }
	  
	  /**
	   * Returns specified text as string.
	   * @param id  The id of the text.
	   * @return    A text as String.
	   */  
	  public static String getString(int id)
	  {
	    return new String(getChars(id));
	  }
	
}
